//package com.plian.system.service.yth.impl;
//
//import com.baomidou.dynamic.datasource.annotation.DS;
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
//import com.plian.Tools.CollectionUtil;
//import com.plian.Tools.DateUtil;
//import com.plian.system.entity.yth.nsgl.SznbAuditPlan;
//import com.plian.system.mapper.yth.nsgl.SznbAuditPlanMapper;
//import com.plian.system.service.yth.ISznbAuditPlanService;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Propagation;
//import org.springframework.transaction.annotation.Transactional;
//
//import java.time.ZoneId;
//import java.util.*;
//
///**
// * 数据采集-内审工作年度工作计划备案主表实体类
// *
// * @author baiyang
// * @since 2023-03-14
// */
//@Slf4j
//@Service
//@DS("slave_1")
//public class SznbAuditPlanServiceImpl extends ServiceImpl<SznbAuditPlanMapper, SznbAuditPlan> implements ISznbAuditPlanService {
//
//    private final String YTH_DATASOURCE_TYPE = "3";
//
//
//
//    @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
//    @DS("slave_1")
//    @Override
//    public List<IamInternalAuditOrganizationVO> getSyncData(Date startTime, Date endTime) {
//        List<IamInternalAuditOrganizationVO> iamInternalAuditOrganizationVOS = new ArrayList<>();
//        List<SznbAuditPlan> ythAuditPlans = list(new LambdaQueryWrapper<SznbAuditPlan>()
//                .gt(Optional.ofNullable(startTime).isPresent(), SznbAuditPlan::getCreateTime, startTime)
//                .le(Optional.ofNullable(endTime).isPresent(), SznbAuditPlan::getCreateTime, endTime)
//        );
//        if (CollectionUtil.isNotEmpty(ythAuditPlans)) {
//            iamInternalAuditOrganizationVOS = conversion(ythAuditPlans);
//        }
//        return iamInternalAuditOrganizationVOS;
//    }
//
//    private List<IamInternalAuditOrganizationVO> conversion(List<SznbAuditPlan> ythAuditPlans) {
//
//        List<IamInternalAuditOrganizationVO> iamInternalAuditOrganizationVOS = new ArrayList<>();
//
//        for (SznbAuditPlan ythAuditPlan : ythAuditPlans) {
//            IamInternalAuditOrganizationVO auditOrganizationVO = new IamInternalAuditOrganizationVO();
//            auditOrganizationVO.setEnterpriseId(Objects.toString(ythAuditPlan.getReportOrgId(), null));
//            auditOrganizationVO.setEnterpriseName(ythAuditPlan.getReportOrgName());
//            auditOrganizationVO.setInstitutionName(ythAuditPlan.getOrgName());
//            auditOrganizationVO.setFullInternalAuditNum(ythAuditPlan.getInternalAuditorsNumber() != null ? ythAuditPlan.getInternalAuditorsNumber().intValue() : null);
//            auditOrganizationVO.setFullTimeAuditNum(ythAuditPlan.getSpecialStaffNumber() != null ? ythAuditPlan.getSpecialStaffNumber().intValue() : null);
//            auditOrganizationVO.setFillingYear(ythAuditPlan.getYear());
//            auditOrganizationVO.setFillingTime(ythAuditPlan.getReportTime() != null ? DateUtil.parse(DateUtil.formatDate(Date.from(ythAuditPlan.getReportTime().atStartOfDay().atZone(ZoneId.systemDefault()).toInstant())), DateUtil.PATTERN_DATE) : null);
//            auditOrganizationVO.setDesignInternalAuditFlag(ythAuditPlan.getIsAuditSystem() != null ? ythAuditPlan.getIsAuditSystem().intValue() : null);
//            auditOrganizationVO.setDataSource(YTH_DATASOURCE_TYPE);
//            auditOrganizationVO.setDataSourceId(ythAuditPlan.getId().toString());
//            iamInternalAuditOrganizationVOS.add(auditOrganizationVO);
//        }
//        return iamInternalAuditOrganizationVOS;
//    }
//
//
//}
